{include file="public/header"/}



<div id="container" style="overflow-y: auto;">
   <div class="row" style="margin:0px;">
      <div class="col-lg-12">
         <h3 class="page-header" style="font-size: 20px;"><i class="am-icon-cubes"></i>  所有网站数据总览</h3>
       </div>   
   </div> 


   <div class="row" style="margin: 0px;">

        <form method="post" action="/manager/index/index" class="layui-form-item" style="width: 30%;position: relative;margin-left: 5%;">
            <input type="text" name="key"  class="layui-input">
            <input class="layui-btn" type='submit' style="position:absolute;right: 0px;top:0px;" value="搜索">
        </form>
       
   </div>
  
 
   <div  style="margin-top: 5px;">

    <div class="selist" style="width: 90%;margin:5px auto">
        <table class="table">
            <thead>
            <tr>
                <th>web</th>
                <th>正在谈话人数</th>
                <th>在线客服人数</th>
                <th>正在排队人数</th>
                <th>接入会话总人数</th>
                <th>今日会话量</th>
                <th>会话总量</th>
                <th>今日留言量</th>
                <th>留言总量</th>
                <th>过期时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="datasheet">

              {if $data}

                {volist name='data' id='v'}
                   <tr>
                       <td>{$v.web}</td>
                       <td>{$v.talk}</td>
                       <td>{$v.service}</td>
                       <td>{$v.wait}</td>
                       <td>{$v.visited}</td>
                       <td>{$v.nowchat}</td>
                       <td>{$v.totalchat}</td>
                       <td>{$v.nowmsg}</td>
                       <td>{$v.totalmsg}</td>
                       <td><span id="exp_{$v.web}" onclick="editexp('exp_{$v.web}', '{$v.web}')">{$v.exp_timestamp}</span></td>
                       {if $v.state == 'open'}
                         <td><button class="btn btn-danger" onclick="manager('{$v.web}','close')">禁用</button></td>
                       {else}
                          <td><button class="btn btn-success" onclick="manager('{$v.web}','open')">解禁</button></td>
                       {/if}
                     
                   </tr>     
                  
                {/volist}

              {else}
              
                 <tr>
                    <td colspan='10'><center>没有相关数据</center></td>
                 </tr>
              
              {/if}  
        
            </tbody>
            {$page}

        </table>

      
        
    </div>

 
       
   </div>
   
   
</div>
<script>

    var manager = function (str, type) {
        $.ajax({
            url: "{:url('manager/set/change')}",
            type: 'post',
            data: {business_id: str, type: type},
            success: function (res) {
                if (res) {
                    layer.msg('更改成功！', {
                        icon: 1, end: function () {
                            location.reload();
                        }
                    });
                } else {
                    layer.msg('更改失败！', {icon: 2});
                }
            }
        })
    };

    var editexp = function (str, business_id) {
        var date = $('#' + str).html();
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                title: '更改过期时间',
                type: 1,
                area: ['300px', '250px'],
                content: '<div style="text-align:center"><div style="width:120px;font-size:18px;border:1px solid #999;margin:60px auto;" id="date_edit">'+date+'</div><button class="layui-btn" onclick="saveexp(\''+business_id+'\')">确定</button><script>layui.use("laydate", function(){layui.laydate.render({"elem": "#date_edit"});});<\/script></div>'
            });
        });
    };

    function saveexp(business_id) {
        var exp_time = $('#date_edit').html();
        $.ajax({
            url: "{:url('manager/set/saveexp')}",
            type: 'post',
            data: {business_id: business_id, exp_time: exp_time},
            success: function (res) {
                if (res) {
                    layer.msg('更改成功！', {
                        icon: 1, end: function () {
                            $('#exp_' + business_id).html(exp_time);
                            layer.closeAll();
                        }
                    });
                } else {
                    layer.msg('更改失败！', {icon: 2});
                }
            }
        })
    }
</script>



{include file="public/footer"/}


